function res = add_parity_bit( vec )
    bit = mod( sum(vec), 2 );
    res = [vec, bit];
end
